package org.example.member.controller.front;

import org.example.core.utils.R;
import org.example.member.service.MemberCollectSkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 小杰_cc
 * @version 1.0
 */
@RestController
@RequestMapping("/ums/front/mCollect")
public class MemberCollectSkuFrontController {

    @Autowired
    private MemberCollectSkuService memberCollectSkuService;

    /**
     * 添加收藏
     * @param spuId
     * @return
     */
    @PostMapping("/add/{spuId}")
    public R<?> addCollect(@PathVariable("spuId") Long spuId){
        return memberCollectSkuService.addCollect(spuId);
    }

    /**
     * 判断是否收藏
     * @param spuId
     * @return
     */
    @GetMapping("/isCollect/{spuId}")
    public R<?> isCollect(@PathVariable("spuId") Long spuId){
        boolean mark = memberCollectSkuService.isCollect(spuId);
        return R.ok(mark);
    }

    /**
     * 删除收藏
     * @param spuIds
     * @return
     */
    @DeleteMapping("/delete")
    public R<?> delete(@RequestBody Long[] spuIds){
        memberCollectSkuService.delete(spuIds);
        return R.ok();
    }

    /**
     * 查询收藏商品详情
     * @return
     */
    @GetMapping("/spuIds")
    public R<List<Long>> queryCollectSpuIds(){
        List<Long> spuIds = memberCollectSkuService.queryCollectSpuIds();
        return R.ok(spuIds);
    }

}
